There are 2 sorted arrays A and B of size n each. Write an algorithm to find the median of the array obtained after merging the above 2 arrays(i.e. array of length 2n). The complexity should be O(log(n))...
Given two sorted arrays of size m and n respectively, you are tasked with finding the element that would be at the k’th position of the final sorted array....
Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array. Examples :...
Given an array arr[] consisting of N integers, the task is to find the second largest element in the given array using N+log2(N) – 2 comparisons....
Given an array, arr[] of length N, and an integer K. The value of the i-th element is arr[i]. The task is to find the maximum number of groups such that for each group the product of the number of elements in that group and the minimum element is at least K....
Given two numbers and . The task is to find the number of ways in which a can be represented by a set such that and the summation of these numbers is equal to a. Also (maximum size of the set cannot exceed m)....
Given an array that represents elements of arithmetic progression in order. One element is missing in the progression, find the missing number....
Given an array arr[] of integers, the task is to find the maximum sum sub-array among all the possible sub-arrays.Examples:...
Given an array arr[] consisting of integers and queries Q of the form (L, R), the task is to check whether any non-repeating element is present within indices [L, R](1 based indexing) or not. If there is at least one non-repeating element, then print “Yes”. Otherwise, print “No”. Examples:...
The standard Tower of Hanoi problem is explained here . In the standard problem, all the disc transactions are considered identical. Given a 3×3 matrix costs[][] containing the costs of transfer of disc between the rods where costs[i][j] stores the cost of transferring a disc from rod i to rod j. Cost of transfer between the same rod is 0. Hence the diagonal elements of the cost matrix are all 0s. The task is to print the minimum cost in which all the N discs are transferred from rod 1 to rod 3.Examples:...
Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers....